package com.github.szhittech.service.ext;


import com.github.szhittech.bean.LibrariesBean;
import com.github.szhittech.bean.LibraryBean;
import com.github.szhittech.util.Logc;
import com.github.szhittech.util.WordUtil;

import org.gradle.api.Project;

import java.util.Map;

public class LibraryCompile {
    private Project project;
    private LibrariesBean librariesBean;

    public LibraryCompile(Project project, LibrariesBean librariesBean) {
        this.project = project;
        this.librariesBean = librariesBean;
    }

    public String get(String name) {
        if (librariesBean == null) {
            throw new IllegalStateException(WordUtil.STRING_1 + librariesBean);
        }
        Map<String, LibraryBean> mapping = librariesBean.getNameMapping();
        if (!mapping.containsKey(name)) {
            throw new IllegalStateException(WordUtil.STRING_2 + name);
        }

        String library = mapping.get(name).getFullyQualifiedName();
        Logc.e(WordUtil.STRING_3 + library);
        return library;
    }
}
